// JavaScript Document
var _ajax_url = '/ajax/article.html';
function logindone(id,username){
	if(id>0){
		$('#loginStatus').hide()
		.html('欢迎您 <span>'+username+'</span> <a href="/logout.html">退出</a>')
		.fadeIn()
		$('#login').slideUp()
	}
}
function loadreview(){
	var id = $('#articleid').val()
	$('#reviewList').loadContent('评论列表',{url:_ajax_url,query:'s='+Math.random()+'&id='+$('#articleid').val()});
	var i = parseInt($('#reviewcount').html());
	$('.reviewcount').html(i)
}
$(function(){
	var id = $('#articleid').val()
	$('#submitReview').click(function(){
		if($('#content').val().length<=3){
			alert('请填写评论的内容!');
			$('#content').focus()
			return;
		}
		var s = $('#reviewfrm').serialize();
		$.doCmd('SubmitReview',{method:'post',url:_ajax_url,query:s,complete:function(xhr){
			var html = xhr.responseText;
			if(html&&html!=''){
				$(html)
				.hide()
				.prependTo('#reviewList')
				.slideDown()
				var i = 1+parseInt($('#reviewcount').html());
				$('.reviewcount').html(i)
			}
		}});
	});
	$('#btnLogin').click(function(){
		$('#login').toggle()
	});
	$('#editorblog').loadContent('ArticleEditor',{url:_ajax_url,query:'s='+Math.random()+'&id='+$('#masterid').val()});
	$('#reviewList .support,#reviewList .combat').live('click',function(){
		var id=this.rel,mode=$(this).hasClass('support')?'support':'combat',$this = $(this);
			s = 'id='+id+'&mode='+mode;
		if($this.data('ok')!=1){
			$.doCmd('ReviewOKNG',{url:_ajax_url,query:s,complete:function(xhr){
				$this.data('ok',1)
				$('font',$this).html(xhr.responseText)
				$this.html('已'+$this.html())
			}});
		}else{alert('您已经支持了他了')}
		
	});
})
